<?php
namespace App\Rules\Admin;

class AdminUserSaveRule extends \App\Rules\FormRequest
{
    /**
     * 访问权限验证
     * @return bool
     */
    public function authorize(){
        return true;
    }

    /**
     * 验证规则
     * @return array
     */
    public function rules(){
        return [
            'name' => 'required|max:255',
            'role_id' => 'required|integer|gt:0',
            'status' => 'required|in:0,1',
            'sex' => 'in:0,1,2',
            'nickname' => 'max:255',
            'real_name' => 'max:255',
            'en_name' => 'max:255',
            'position' => 'max:255',
            'phone' => 'max:20',
        ];
    }

    /**
     * 验证消息
     * @return array
     */
    public function messages(){
        return [
            'name.required' => '请输入登录名称',
            'name.max' => '登录名称已超过255个字符',
            'role_id.required' => '请输选择角色',
            'role_id.integer' => '选择角色规格不正确',
            'role_id.gt' => '选择角色不存在',
            'status.required' => '请选择登录状态',
            'status.in' => '登录状态出错',
            'sex.in' => '性别出错',
            'nickname.max' => '呢称不能超过255个字符',
            'real_name.max' => '真实姓名不能超过255个字符',
            'en_name.max' => '英文名不能超过255个字符',
            'position.max' => '职称不能超过255个字符',
            'phone.max' => '职称不能超过20个字符',
        ];
    }
}
